package cqrtplm.entity;

import lombok.Data;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;

@Data
@Entity
@Table(name = "rt_flow_task_claim")
public class FlowTaskClaimDO {
    @Id
    private String key;
    private String taskId;
    private String userId;
    private String userName;
    private String claimMsg;
    private String taskDefKey;
    private Date createstamp;
    private Date updatestamp;
    private Date modifystamp;
    private Long updatecount;
    private Long markfordelete;

    public FlowTaskClaimDO() {
    }

    public FlowTaskClaimDO(String key, String taskId, String taskDefKey, String userId, String userName, String claimMsg) {
        this.key = key;
        this.taskId = taskId;
        this.taskDefKey = taskDefKey;
        this.userId = userId;
        this.userName = userName;
        this.claimMsg = claimMsg;
    }

    public static void fillCommonFieldForCreate(FlowTaskClaimDO entityBaseDO, Date date) {
        entityBaseDO.setCreatestamp(date);
        entityBaseDO.setUpdatestamp(date);
        entityBaseDO.setModifystamp(date);
        entityBaseDO.setUpdatecount(0L);
        entityBaseDO.setMarkfordelete(0L);
    }
    public static void fillCommonFieldForUpdate(FlowTaskClaimDO entityBaseDO, Date date) {
        entityBaseDO.setUpdatestamp(date);
        entityBaseDO.setModifystamp(date);
        if (entityBaseDO.getUpdatecount() == null) {
            entityBaseDO.setUpdatecount(0L);
        }

        entityBaseDO.setUpdatecount(entityBaseDO.getUpdatecount() + 1L);
    }
}
